package com.qfedu.tantu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qfedu.tantu.dao.ArticleDao;
import com.qfedu.tantu.entity.Article;
import com.qfedu.tantu.service.intf.ArticleService;
import com.qfedu.tantu.vo.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {
    @Resource
    private ArticleDao dao;

    @Override
    public R query(int id) {
        if (id > 0) {
            QueryWrapper<Article> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("id", id);
            return R.ok(dao.selectOne(queryWrapper));

        }

        return R.fail();
    }

    @Override
    public R indexQuery() {
        return R.ok(dao.all());
    }
}

